Skip to content

[python-dateutil] Add missing stubs #14326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 7, 2025

Conversation

donBarbos
Copy link
Contributor

  • Fix and improve few stubs

This comment has been minimized.

This comment has been minimized.

freq,
dtstart: datetime.date | None = None,
freq: Literal[0, 1, 2, 3, 4, 5, 6],
dtstart: datetime.datetime | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old annotation was correct. rrule converts a date to a datetime:

https://github.com/dateutil/dateutil/blob/35ed87a02ad777428a9da84ead4d8425b533d4a9/src/dateutil/rrule.py#L441

I'd also be fine with using datetime.datetime | datetime.date. Although technically redundant, it's a bit clearer. (Also deriving datetime from date was a mistake, in my opinion.)

See also the prefect primer hits.

self,
s: str,
*,
dtstart: datetime.datetime | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dtstart: datetime.datetime | None = None,
dtstart: datetime.date | None = None,

See above.

@srittau
Copy link
Collaborator

srittau commented Jul 7, 2025

The homeassistant primer hit is a bit unfortunate, but can easily be worked around with an explicit type annotation for the constant dict.

@srittau
Copy link
Collaborator

srittau commented Jul 7, 2025

Huh, new pyright errors. They seem legit, but strange that they're only appearing now. Probably due to a newer pyright version.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once you've squashed the new pyright errors.

Copy link
Contributor

github-actions bot commented Jul 7, 2025

Diff from mypy_primer, showing the effect of this PR on open source code:

core (https://github.com/home-assistant/core)
+ homeassistant/components/habitica/util.py:81: error: Argument "freq" to "rrule" has incompatible type "int"; expected "Literal[0, 1, 2, 3, 4, 5, 6]"  [arg-type]

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/client/schemas/schedules.py:290: error: Argument 1 to "append" of "list" has incompatible type "rrule"; expected "rruleset"  [arg-type]

@srittau srittau merged commit 98bb239 into python:main Jul 7, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants